<?php
/**
 * index.php     Zhuayi 跳转
 *
 * @copyright    (C) 2005 - 2010  Zhuayi
 * @licenes      http://www.zhuayi.net
 * @lastmodify   2010-10-27
 * @author       zhuayi
 * @QQ			 2179942
 */
class api_action extends zhuayi
{

	function __construct()
	{
		parent::__construct();
		$this->db = parent::db();
	}
	
	/* 管理员操作 api接口 */
	function index()
	{
		$perpage = 20;
		
		$limit = ($_GET['page']-1)*$perpage.','.$perpage;
		/* 查询 */
		$list = api_modle::api_list(array(),$limit);
		$page=new page(array('total'=>api_modle::api_num(),'perpage'=>$perpage,'ajax'=>'ajax_page','page_css'=>'page_css','pagebarnum'=>5));
		require $this->load_tpl('api_index');
	}
	
	/* 编辑api接口 */
	function edit($id)
	{
		$info = api_modle::api(array('id'=>$id));
		require $this->load_tpl('api_edit');
	}
	
	/* 添加api接口 */
	function add()
	{
		require $this->load_tpl('api_edit');
	}
	
	/* 入库 */
	function info()
	{
		/* 载入文件上传类 */
		$upload = $this->load_class('upload',true);
		
		$_POST['litpic'] = $upload->copy($_FILES['file1'],$_POST['litpic'],'api',$_POST['api']);
		
		
		$id = api_modle::api_info($_POST);
		
		if (!is_numeric($id))
		{
			exit(message::ret_json('-1','操作失败...'));
		}
		echo $id;
		exit;
	}
	
	/* 删除 */
	function del()
	{
		$reset = api_modle::api_del($_POST['id']);
		exit(message::ret_json($reset,'操作失败...'));
	}
	
	
	



}

?>